﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using h2sbk_sharp.DoNetExt;
using H2SDB;

namespace h2sbk_sharp.Controllers
{
    public class CountController : ApiController
    {
        [HttpGet, HttpPost]
        public HttpResponseMessage historyCurve (int terminalid, int pointid, DateTime optime, DateTime edtime)
        {
            historyCurveResult[] rtv = null;
            using (h2sDataContext db = new h2sDataContext())
            {
                rtv = db.historyCurve(terminalid, pointid, optime, edtime).ToArray();
            }
            return rtv.ToHttpResponseMessage();
        }

        [HttpGet, HttpPost]
        public HttpResponseMessage overproof(double h2s, DateTime optime, DateTime edtime)
        {
            using (h2sDataContext db = new h2sDataContext())
            {
                return db.overproof(h2s, optime, edtime).ToHttpResponseMessage();
            }
        }

        [HttpGet, HttpPost]
        public HttpResponseMessage pointover(double h2s, DateTime optime, DateTime edtime)
        {
            using (h2sDataContext db = new h2sDataContext())
            {
                return db.pointOver(h2s, optime, edtime).ToHttpResponseMessage();
            }
        }

        [HttpGet, HttpPost]
        public HttpResponseMessage dayrecord(int terminalid, int pointid, DateTime date)
        {
            using (h2sDataContext db = new h2sDataContext())
            {
                return db.getDayH2S(terminalid, pointid, date).ToHttpResponseMessage();
            }
        }
    }
}
